﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Xeno.Core;

namespace XenoStudio
{
    public partial class Shadey : Form
    {
        public XenoEffectNode MasterNode { get; set; }
        public Shadey()
        {
            InitializeComponent();
        }

        private void Shadey_Load(object sender, EventArgs e)
        {
            MasterNode = new XenoEffectNode("MasterNode", EffectNodeType.EngineInput);
            MasterNode.UIWidth = 150;
            MasterNode.UIHeight = 250;
            MasterNode.UIPos = new OpenTK.Vector2(40.0f, 50.0f);

            MasterNode.AddIn(EffectParameterType.Anything, "Diffuse", "Diffuse Color");
            MasterNode.AddIn(EffectParameterType.Anything, "Normal", "Normal");
            ShadeyEditor.AddNode(MasterNode);
            UpdateTree();
        }
        public void UpdateTree()
        {
            NodePal.Nodes.Clear();
            foreach (var n in XenoFX.NodeTypes)
            {
                vTreeNode tn = new vTreeNode(n.ID);
                NodePal.Nodes.Add(tn);
                tn.DescriptionText = "Type:" + n.Type.ToString();
                //tn.DescriptionTextColor = Color.LemonChiffon;
                tn.UseThemeTextColor = true;
                tn.ItemHeight = 31;
                tn.ExtraWidth = 30;

            }
        }
        private void shadeyEditorArea1_Load(object sender, EventArgs e)
        {

        }

        private void NodePal_AfterSelect(object sender, vTreeViewEventArgs e)
        {
            var ntype = e.Node.Text;
            var en = XenoFX.GetNodeType(ntype);
            var an = en.CreateNew();
            an.UIPos = new OpenTK.Vector2(ShadeyEditor.ClientRectangle.Width / 2, ShadeyEditor.ClientRectangle.Height / 2);
            an.UIWidth = 240;
            if (an.In.Count == 0)
            {
                an.UIWidth /= 2;
            }
            an.UIHeight = 60 + (20 * an.In.Count);
            ShadeyEditor.AddNode(an);


        }
    }
}
